#include"../head.h"

int n;
map<int, int> arr;
int ans = 0;

int main(){
    cin >> n;
    for(int i = 0; i < n; i ++){
        int a;
        cin >> a;
        auto it = arr.find(a);
        if(it == arr.end()){
            arr.insert(pair<int, int>(a, 1));
        }
        else{
            it->second ++;
        }
    }
    int max = -1;
    for(auto it : arr){
        cout << it.first << "   " << it.second << endl;
        if(it.second > max){
            max = it.second;
            ans = it.first;
        } 
    }

    cout << ans << endl;

    return 0;
}